//案例id
var alId = globalFun.GetQueryString("id"),
  shareMsg = {};
var shareId = globalFun.GetQueryString("share");
alId = alId ? alId : 36;

//案例详情
$.ajax({
  type: "post",
  url: apicom + "mobile/after/case/caseManageMentMsg",
  data: {
    id: alId
  },
  success: function(res) {
    if (typeof res == "string") {
      var data = JSON.parse(res);
    } else {
      var data = res;
    }
    var shopList = '';
    if (data.code == 1) {
      $(".nav-zt img").attr("src", data.imageAddress);
      $(".main_biaoti").html(data.title);
      $(".main-yuedu").html(data.readNum);
      $(".main-time").html(data.createdTime.split(" ")[0]);
      $("#al_content").html(data.content);
      //分享信息
      shareMsg.title = data.title;
      shareMsg.imageAddress = data.imageAddress;
      shareMsg.content = "pjyc";
      shareMsg.type = 1;
      //相关服务
      $(".relatedServices_pic img").attr("src", data.serviceImageAddress);
      $(".relatedServices_pic").attr("serviceId", data.serviceId);
      $(".relatedServices_mb1").html(data.serviceTitle);
      $(".relatedServices-rmb").html(data.price);
      //相关商品
      if (data.productVOList && data.productVOList[0]) {
        $.each(data.productVOList, function(index, val) {
          shopList += '<li shopId="' + val.id + '"><div class="relatedGoodsL-pic"><img src="' + val.attachment + '"/></div><p class="relatedGoodsL-mc">' + val.productName + '</p><p class="relatedGoodsL-js">' + val.title + '</p><p class="relatedGoodsL-jg">¥<span class="relatedGoodsL-jq">' + val.price + '</span></p></li>';
        });
        $(".relatedGoods-list").html(shopList);
      } else {
        $(".relatedGoods-list").html("");
      }

    }
    if (data.code == 0) {
      tips(data.msg);
    }
  },
  error: function(err) {
    tips("服务器错误!");
  }

});
//分享
// Auth();
$('.navFx-img').on('click', function() {
  //		if(Auth()){
  //		var data = {
  //			uuid:user_info.uuid,
  //			phone:user_info.phone,
  //			memberId:user_info.id
  //		}
  //		console.log(user_info.id)
  //		$.ajax({
  //			type:"post",
  //		 	url:apicom + "mobile/after/member/memberdetail",
  //		 	data:data,
  //		 	async: false,
  //			dataType: "json",
  //			success:function(res){
  //				if(typeof(res) == 'string'){
  //					res = JSON.parse(res);
  //				}
  //				if(res.content.isHunter == 1){
  //					isHunter = user_info.id
  //
  //				} else{
  //					isHunter = ''
  //				}
  //			},
  //			error:function(err){
  //				console.log(err)
  //			}
  //		})
  //	} else{
  //		sessionStorage.setItem('history', window.location.href);
  //		toClientLogin(location.href)
  //	}

  //		var $self = $(this)
  //		if($self.hasClass("disabled")){
  //			return false
  //		}
  //		$self.addClass("disabled")
  //		setTimeout(function(){
  //			$self.removeClass("disabled")
  //		},1000)

  if (!Auth()) {
    toClientLogin();
  } else {
    shareMsg.url = location.href + "&=share" + user_info.id;
    fenxiang(shareMsg);
  }

})

//分享
function fenxiang(data) {
  if (mark == 1) {
    setupWebViewJavascriptBridge(function(bridge) {
      bridge.callHandler('jsToClientShare', data, function(resp) {});
    });
  } else if (mark == 0) {
    //var result = lase;
    data = JSON.stringify(data);
    window.stub.jsToClientShare(data); //用接口stub, 通过调用内部类中的方法jsMethod给java传回result。

  }
}

//返回
$('.nav1-img').on('click', function() {
  if (globalFun.GetQueryString('from') == "app") {
    houtui()
  } else {
    window.history.go(-1);
  }
})

function houtui() {
  var ua = navigator.userAgent.toLowerCase();
  if (/pjyc_i/.test(ua)) {
    setupWebViewJavascriptBridge(function(bridge) {
      bridge.callHandler('goBack', function(resp) {});
    });
  } else if (/pujiyicheng/.test(ua)) {
    //var result = lase;
    window.stub.goBack(); //用接口stub, 通过调用内部类中的方法jsMethod给java传回result。

  }
}
//服务团队
$('.relatedServices_pic').on('click', function() {
  var fwId = $(this).attr("serviceid");
  window.location.href = '../homektxq/home_fwxq.html?id=' + fwId + "&share=" + shareId;;
})
//商品列表跳转到商品详情
$('.relatedGoods-list').on('click', 'li', function() {
  var shopId = $(this).attr("shopId");
  window.location.href = '../shopDetail/shopDetail.html?id=' + shopId + "&share=" + shareId;
})